package com.example.eddie.test.MyAdapter;

import android.content.Context;
import android.support.annotation.IdRes;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.eddie.test.PoJo.UserSettingPoJo;
import com.example.eddie.test.R;

import java.util.List;

public class UserSettingAdapter extends ArrayAdapter {

    private Context context;
    private int resource;
    private List<UserSettingPoJo> objects;

    public UserSettingAdapter(@NonNull Context context, @LayoutRes int resource,  @NonNull List objects) {
        super(context, resource, objects);

        this.context = context;
        this.resource = resource;
        this.objects = objects;

    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View view, @NonNull ViewGroup parent) {

        view = LayoutInflater.from(context).inflate(resource,parent,false);

        ImageView img = view.findViewById(R.id.setting_img);
        TextView text = view.findViewById(R.id.text);

        img.setImageDrawable(objects.get(position).getDrawable());
        text.setText(objects.get(position).getText());

        return view;
    }
}
